package main

import (
	"html/template"
	"net/http"
	"strings"
	"tcsc/cron"
	_ "tcsc/routers"

	"github.com/astaxie/beego"
)

func tipcheck(alone, more string) string {
	mores := strings.Split(more, ",")
	for _, v := range mores {
		if v == alone {
			return "checked"
		}
	}
	return ""
}

func page_not_found(rw http.ResponseWriter, r *http.Request) {
	t, _ := template.New("404.tpl").ParseFiles(beego.BConfig.WebConfig.ViewsPath + "/404.tpl")
	data := make(map[string]interface{})
	data["content"] = "page not found"
	t.Execute(rw, data)
}
func main() {
	beego.SetStaticPath("/MP_verify_tvtfnqXzEcjQYcF4.txt", "MP_verify_tvtfnqXzEcjQYcF4.txt")
	beego.SetStaticPath("/.well-known/pki-validation/fileauth.txt", "fileauth.txt")
	// models.ClearLog()
	cron.Init()
	beego.AddFuncMap("tipcheck", tipcheck)
	beego.ErrorHandler("404", page_not_found)
	beego.SetLogger("file", `{"filename":"logs/debug.log","maxdays":30,"daily":true}`)
	beego.Run()
}
